<?php

namespace Admin\Controller;

/**
 * 公式编辑器控制器
 *
 * @author zhiyuan
 *        
 */
class JmeditorController extends AdminController {
	public function index() {
		$mytext = '<p>我的公式 <span class="mathquill-rendered-math" style="font-size:undefined;"><span class="fraction non-leaf" mathquill-command-id="4"><span class="numerator" mathquill-block-id="5"><span mathquill-command-id="8">1</span></span><span class="denominator" mathquill-block-id="6"><span mathquill-command-id="9">x+3</span></span><span style="display:inline-block;width:0">&nbsp;</span></span><span class="" mathquill-command-id="16">sin</span><span class="non-leaf" mathquill-command-id="17"><span style="transform: scale(1.0029, 1.06522);" class="scaled paren">(</span><span class="non-leaf" mathquill-block-id="18"><span class="non-leaf" mathquill-command-id="20"><span style="transform: scale(1.0029, 1.06522);" class="scaled paren">|</span><span class="non-leaf" mathquill-block-id="21"><var mathquill-command-id="23">x</var></span><span style="transform: scale(1.0029, 1.06522);" class="scaled paren">|</span></span></span><span style="transform: scale(1.0029, 1.06522);" class="scaled paren">)</span></span></span><span> </span>；<br></p><table style="width: 500px;" cellpadding="1" cellspacing="1" border="1"><tbody><tr><td>爱上<br></td><td>是<br></td></tr><tr><td>&nbsp;是<br></td><td>十分<br></td></tr><tr><td>&nbsp;十分<br></td><td>三<br></td></tr></tbody></table><p><br></p>';
		$this->assign ( 'mytext', $mytext );
		$this->meta_title = '公式编辑器示例';
		$this->display ();
	}
	public function tcpdf_test() {
		$mytext = '<p>我的公式 <span class="mathquill-rendered-math" style="font-size:undefined;"><span class="fraction non-leaf" mathquill-command-id="4"><span class="numerator" mathquill-block-id="5"><span mathquill-command-id="8">1</span></span><span class="denominator" mathquill-block-id="6"><span mathquill-command-id="9">x+3</span></span><span style="display:inline-block;width:0">&nbsp;</span></span><span class="" mathquill-command-id="16">sin</span><span class="non-leaf" mathquill-command-id="17"><span style="transform: scale(1.0029, 1.06522);" class="scaled paren">(</span><span class="non-leaf" mathquill-block-id="18"><span class="non-leaf" mathquill-command-id="20"><span style="transform: scale(1.0029, 1.06522);" class="scaled paren">|</span><span class="non-leaf" mathquill-block-id="21"><var mathquill-command-id="23">x</var></span><span style="transform: scale(1.0029, 1.06522);" class="scaled paren">|</span></span></span><span style="transform: scale(1.0029, 1.06522);" class="scaled paren">)</span></span></span><span> </span>；<br></p><table style="width: 500px;" cellpadding="1" cellspacing="1" border="1"><tbody><tr><td>爱上<br></td><td>是<br></td></tr><tr><td>&nbsp;是<br></td><td>十分<br></td></tr><tr><td>&nbsp;十分<br></td><td>三<br></td></tr></tbody></table><p><br></p>';
		require_once 'ThinkPHP/Library/tcpdf/tcpdf.php';
		require_once 'ThinkPHP/Library/tcpdf/examples/tcpdf_include.php';
		$pdf = new \TCPDF ( PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false );
		// set document information
		$pdf->SetCreator ( PDF_CREATOR );
		$pdf->SetAuthor ( 'Nicola Asuni' );
		$pdf->SetTitle ( 'TCPDF Example 001' );
		$pdf->SetSubject ( 'TCPDF Tutorial' );
		$pdf->SetKeywords ( 'TCPDF, PDF, example, test, guide' );
		
		// set default header data
		$pdf->SetHeaderData ('paper_header.png', '', '', array (
				0,
				64,
				255 
		), array (
				0,
				64,
				128 
		) );
		$pdf->setFooterData ( array (
				0,
				64,
				0 
		), array (
				0,
				64,
				128 
		) );
		
		// set header and footer fonts
		$pdf->setHeaderFont ( Array (
				PDF_FONT_NAME_MAIN,
				'',
				PDF_FONT_SIZE_MAIN 
		) );
		$pdf->setFooterFont ( Array (
				PDF_FONT_NAME_DATA,
				'',
				PDF_FONT_SIZE_DATA 
		) );
		
		// set default monospaced font
		$pdf->SetDefaultMonospacedFont ( PDF_FONT_MONOSPACED );
		
		// set margins
		$pdf->SetMargins ( PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT );
		$pdf->SetHeaderMargin ( PDF_MARGIN_HEADER );
		$pdf->SetFooterMargin ( PDF_MARGIN_FOOTER );
		
		// set auto page breaks
		$pdf->SetAutoPageBreak ( TRUE, PDF_MARGIN_BOTTOM );
		
		// set image scale factor
		$pdf->setImageScale ( PDF_IMAGE_SCALE_RATIO );
		
		// set some language-dependent strings (optional)
		if (@file_exists ( 'ThinkPHP/Library/tcpdf/lang/cni.php' )) {
			require_once ('ThinkPHP/Library/tcpdf/lang/cni.php');
			$pdf->setLanguageArray ( $l );
		}
		
		// ---------------------------------------------------------
		
		// set default font subsetting mode
		$pdf->setFontSubsetting ( true );
		
		// Set font
		// dejavusans is a UTF-8 Unicode font, if you only need to
		// print standard ASCII chars, you can use core fonts like
		// helvetica or times to reduce file size.
		$pdf->SetFont ( 'dejavusans', '', 14, '', true );
		
		// Add a page
		// This method has several options, check the source code documentation for more information.
		$pdf->AddPage ();
		
		// set text shadow effect
		$pdf->setTextShadow ( array (
				'enabled' => true,
				'depth_w' => 0.2,
				'depth_h' => 0.2,
				'color' => array (
						196,
						196,
						196 
				),
				'opacity' => 1,
				'blend_mode' => 'Normal' 
		) );
		
		// Set some content to print
		$html = 'hello world！';
		// Print text using writeHTMLCell()
		$pdf->writeHTMLCell ( 0, 0, '', '', $html, 0, 1, 0, true, '', true );
		
		
		// ---------------------------------------------------------
		
		// Close and output PDF document
		// This method has several options, check the source code documentation for more information.
		$pdf->Output ( 'tcpdf_test.pdf', 'I' );
	}
}

?>